import React, { useState } from 'react'
import axios from 'utils/request'
import { useNavigate } from 'react-router-dom'
import { Form, Input, Button } from 'antd-mobile'
const Login = () => {
  const navigate = useNavigate()
  const onFinish = async (values: any) => {
    const data = await axios.post('/api/login', values)
    localStorage.setItem('token', data.data.token)
    navigate('/basic/home')
  }

  return (
    <div>
      <Form
        name="form"
        onFinish={onFinish}
        footer={
          <Button block type="submit" color="primary" size="large">
            提交
          </Button>
        }
      >
        <Form.Item name="username" label="姓名" rules={[{ required: true }]}>
          <Input placeholder="请输入姓名" />
        </Form.Item>
        <Form.Item name="password" label="密码" rules={[{ required: true }]}>
          <Input placeholder="请输入密码" />
        </Form.Item>
      </Form>
    </div>
  )
}

export default Login
